<template>
  <div class="communication">
    <div class="communication_bgc"><steps :active="active" /></div>
    <div class="communication_body">
      <div class="communication_body_top">
        <span>{{ time }}</span>
<!--        <span>{{ time.m }}</span>-->
<!--        <span>{{ time.d }}，</span>-->
<!--        <span>{{ time.y }}</span>-->
      </div>
      <div class="communication_body_middle">
        <div>问诊室</div>
      </div>
      <communicateList :list="list" />
    </div>
  </div>
</template>

<script>
import communicateList from "@/components/commonComponents/communicateList.vue";
// import getNowDate from "@/utils/time.js";
import steps from "../commonComponents/steps.vue";
import store from "@/store";
import axios from "axios";
export default {
  name: "communication",
  components: { steps, communicateList },
  data() {
    return {
      active: 2,
      time: '',
      appuserInfo:{},
      // list:[],
      list: [
        {
          id: '17',
          imgUrl: "https://q1.qlogo.cn/g?b=qq&nk=1848257116&s=100",
          name: '李华',
          content: '666',
          createTime: '09月28日 20:00',
        },
      ],
    };
  },
  //vuex mutations 定义：
  setUserInfo(state,data){
    state.userInfo=data;
  },

//组件触发：
  setUserInfo1(row, column, event){
    store.commit('setUserInfo',{name:row.name,img:row.img});
  },

//App引用：
  computed:{
    userInfo(){
      return store.state.userInfo;
    }
  },

  //后台无数据会显示一片空白因此先用假数据支撑
  // created() {
  //   // const time = getNowDate();
  //   // this.time = time;
  //   const options = {
  //     method: 'GET',
  //     url: 'http://106.54.189.155:6768/chat/findRoomListByUserId',
  //     headers: {Accept: '*/*'}
  //   };
  //   axios.request(options).then(response=>{
  //     this.list=response.data.data;
  //     console.log(response.data);
  //   }).catch(function (error) {
  //     console.error(error);
  //   });
  // },

  mounted() {
    this.format();
  },

  methods: {
    format() {
      const nowDate = new Date();
      const date = {
        year: nowDate.getFullYear(),
        month: nowDate.getMonth() + 1,
        date: nowDate.getDate(),
      }
      const newmonth = date.month > 10 ? date.month : '0' + date.month
      const day = date.date > 10 ? date.date : '0' + date.date
      this.time = date.year + '.' + newmonth + '.' + day

    }, //获取当前时间

  },


};
</script>

<style lang="scss" scope>
.communication {
  overflow-x: hidden;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background-color: #fafafa;
  overflow-y: auto;
  z-index: 10;
  &_body {
    width: 100%;
    &_middle {
      padding: 5px 20px 15px 20px;
      font-size: 26px;
      font-weight: 540;
      border-bottom: 1px solid #ccc;
    }
    &_top {
      padding: 5px 20px;
      & span {
        color: #666;
        font-size: 17px;
        margin-right: 5px;
      }
    }
  }
}
</style>
